<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=, initial-scale=1.0">
    <title>无序列表的列表项添加点击更改背景色事件</title>
    <style>
        li .current{
            background-color: #ff0;
        }
    </style>
</head>
<body>
    <ul id="box">
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </ul>
</body>

<script>
    var box = document.getElementById("box");
    var lis = box.children;
    box.addEventListener('click',function(e){
        var e = e|| window.event;
        var ele = e.target || e.srcElement;
        
        for (let i = 0; i < lis.length; i++) {
            const element = lis[i];
            element.style.backgroundColor = "";
        }

        ele.style.backgroundColor = "#FF0";
    });
</script>
</html>